/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Actor.weapons;

import Actor.Actor;
import actor.weapons.Weapon;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;

/**
 *
 * @author Eric-Standard
 */
public class SubmachineGun extends Weapon {

    protected Rectangle2D r = new Rectangle2D.Double();
    private int width = 5;
    private int height = 10;
    private static final int DEFAULT_DAMAGE = 10;

    public SubmachineGun(Actor a) {
        this(a, DEFAULT_DAMAGE);
    }

    public SubmachineGun(Actor a, int damage) {
        super(a);
        owner = a;
        this.ammo = 40;
        this.totalAmmo = 400;
        this.clipSize = 40;
        this.damage = damage;
        this.cooldownTimeout = 1000 / 16;
    }

    @Override
    public void act(long dt) {
        super.act(dt);
        if (this.cooldownTime != 0) {
        }
    }

    @Override
    public boolean fire() {
        if (!super.fire()) {
            if (ammo == 0) {
                reload();
            }
            return false;
        }
        Bullet bullet = new Bullet(owner, damage);
        bullet.setAngle(bullet.getAngle() + world.rand.nextGaussian() / 100);
        owner.getWorld().add(bullet);
        return true;
    }

    @Override
    public void draw(Graphics g) {
        g.setColor(Color.GRAY);
        g.drawRect((int) pos.x, (int) pos.y, width, height);
    }

    @Override
    public Rectangle2D getBoundingRectangle() {
        r.setRect(pos.x, pos.y, width, height);
        return r;
    }
}
